import {Injectable} from '@angular/core';

import {CacheService} from '@kylin/cache';

@Injectable({
    providedIn: 'root'
})

export class SkinService {

    constructor(private cacheService: CacheService) {
    }

    change(color: string): Promise<any> {
        this.setSkinColor(color);
        return window['less'].modifyVars({'@primary-color': color});
    }

    getSkinList(): any[] {
        return [
            {
                group: 1, item: [
                    {color: '#1ABC9C'},
                    {color: '#1890FF'},
                    {color: '#ED6E4D'},
                    {color: '#FABB3D'},
                ]
            },
            {
                group: 2, item: [
                    {color: '#AA7AB3'},
                    {color: '#9AD0B9'},
                    {color: '#EA94BE'},
                    {color: '#C1374A'},
                ]
            }
        ];
    }

    defaultSkinColor(): string {
        return '#1890FF';
    }

    getSkinColor(): string {
        const color = this.cacheService.get('skinColor');
        return color || '';
    }

    setSkinColor(color: string) {
        this.cacheService.set('skinColor', color);
    }

}
